package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbSellerMapper;
import com.dongdongshop.pojo.TbSeller;
import com.dongdongshop.pojo.TbSellerExample;
import com.dongdongshop.service.SellerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@com.alibaba.dubbo.config.annotation.Service
public class SellerServiceImpl implements SellerService {

    @Autowired
    private TbSellerMapper tbSellerMapper;

    @Override
    public boolean selectSellerId(TbSeller tbSeller) {
        TbSeller tbSellers = tbSellerMapper.selectSellerId(tbSeller.getSellerId());
        if (tbSellers == null){
            int i = tbSellerMapper.insertSelective(tbSeller);
            return i > 0;
        }else {
            return false;
        }

    }

    @Override
    public TbSeller selectByName(String username) {
        TbSeller tbSeller = tbSellerMapper.selectByName(username);
        return tbSeller;
    }

    @Override
    public List<TbSeller> getInfo(String name, String nickName) {
        List<TbSeller> list = tbSellerMapper.selectByExample(new TbSellerExample());
        return list;
    }

    @Override
    public TbSeller toUpdate(String sellerId) {
        return tbSellerMapper.selectByPrimaryKey(sellerId);
    }

    @Override
    public Boolean update(TbSeller tbSeller) {
        int i = tbSellerMapper.updateByPrimaryKeySelective(tbSeller);
        return i > 0;
    }

}
